<template>
  <div>
    <input @input="input" v-model="msg" type="text" v-focus />
  </div>
</template>

<script>
export default {
  data() {
    return {
      msg: "",
    };
  },
  methods: {
    input() {
      console.log(this.msg, 17);
    },
  },
  created() {},
  directives: {
    // 在模板中启用 v-focus
    focus: {
      /* ... */
      // 指令的定义
      inserted: function (el) {
        el.focus();
      },
    },
  },
};
</script>
<style scoped></style>
